package com.java.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.java.domain.ActivityUser;
import com.java.service.AdminService;
import com.java.service.CoachService;
import com.java.service.CourseService;
import com.java.service.LawService;
import com.java.service.RecordService;
import com.java.service.ReviewService;
import com.java.service.RoomService;
import com.java.service.SiteService;
import com.java.service.SlotService;
import com.java.service.SportService;
import com.java.service.UserService;
import com.java.util.resp.BaseRespone;
import com.java.util.resp.TableRespone;
import com.java.util.servlet.ServletUtil;

@RestController
@RequestMapping("/user")
public class UserDataController {
	@Autowired private AdminService adminService;
	@Autowired private CoachService coachService;
	@Autowired private CourseService courseService;
	@Autowired private LawService lawService;
	@Autowired private RecordService recordService;
	@Autowired private RoomService roomService;
	@Autowired private SiteService siteService;
	@Autowired private SlotService slotService;
	@Autowired private SportService sportService;
	@Autowired private UserService userService;
	@Autowired private ReviewService reviewService;
	
	@GetMapping(value = "/records")
	public TableRespone records(int page, int size) {
		return recordService.getList(ServletUtil.getUserId(), page, size);
	}
	
	@PostMapping(value = "/payRecord")
	public BaseRespone payRecord(String recordId, Integer payStatus) {
		return recordService.payRecord(recordId, payStatus);
	}
	
	@GetMapping(value = "/reviews")
	public TableRespone reviews(int page, int size) {
		return reviewService.getReviewsByUser(ServletUtil.getUserId(), 0, 0);
	}
	
	@GetMapping(value = "/delReview")
	public BaseRespone delReview(String reviewId) {
		return reviewService.delReview(reviewId);
	}
	
	@PostMapping(value = "/updateUser")
	public BaseRespone updateUser(ActivityUser user) {
		user.setUserId(ServletUtil.getUserId());
		return userService.updateUser(user);
	}
	
	@PostMapping(value = "/updatePassword")
	public BaseRespone updatePassword(String password) {
		return userService.updatePassword(ServletUtil.getUserId(), password);
	}
	
}
